package PlaneGame.CODE;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class EnemyBullet extends Enemy{
    int moveType=0;//0表示直走，1表示弹道偏左，2表示弹道偏右
    public EnemyBullet(int x, int y) {
        super();
        this.x=x;
        this.y=y;
        this.speed=5;
        this.width=5;
        this.height=12;
        this.imageNumber=1;
        this.explodeImageNumber=0;
        this.paths= new String[]{"src/PlaneGame/IMAGE/bullet2.png"};
        images=new BufferedImage[imageNumber+explodeImageNumber];
        for (int i = 0; i < images.length; i++) {
            try {
                images[i] = ImageIO.read(new File(paths[i]));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
    @Override
    void init() {
        super.init();
        blood=1;
    }

    @Override
    void move() {
        if (blood>0) {
            if (moveType==1) {
                super.move();
                this.x-=2;
            }else if(moveType==2){
                super.move();
                this.x+=2;
            }else {
                super.move();
            }
        }
    }
}
